This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
fix(ethers_solc): hardcoded import remapping fix #2626
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
When using ethers_solc to compile contracts, remappings have an issue with the hardcoded specific fix for an openzeppelin contracts issue.
I'm not very familiar with the issue described in the doc comments, but it is erroring in situations where it shouldn't be applicable.
Problematic setup
Example import in sol file:
Example remapping:
in this case, the path of the remapping ends in "contracts/" (lib/openzeppelin-contracts/) and the stripped import also starts with "contracts" (contracts/utils/math/Math.sol).
this makes the resolver look at:
lib/openzeppelin-contracts/utils/math/Math.sol
when it should instead look at:
lib/openzeppelin-contracts/contracts/utils/math/Math.sol
Solution
Stripping based on
.ends_with("contracts/")
isn't precise. Better suited for issue regarding the comment is.ends_with("/contracts/")
.In this instance, the remapping correctly would not get flagged, as it is does not end with "/contracts/" (lib/openzeppelin-contracts/).